package com.jt.demo2;

import com.jt.demo2.config.SpringConfig;
import com.jt.demo2.service.Dog;
import com.jt.demo2.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestAspect {
    public static void main(String[] args) {
        ApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        //看上去：userService是目标对象
        //AOP：内部已经封装动态代理规则
        UserService userService = context.getBean(UserService.class);
        //实际上：已经被AOP封装，是一个代理对象
        System.out.println(userService.getClass());//class com.sun.proxy.$Proxy19
        //代理机制：可以扩展方法
        userService.findName();

        System.out.println("----------------------------------------------");
        Dog d = context.getBean(Dog.class);
        d.hello();


    }
}
